// -*- coding: utf-8 -*- 
/**
 * Project: AlgorithmsLearn
 *
 * @author: yanking
 * Create time: 2022-04-12 08:52
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.LeetCodeT.DateTrain;

/**
 * 字符串的占用行
 */
public class NumberOfLines {
    public int[] numberOfLines(int[] widths, String s) {
        int cur = 0, n = s.length(), cnt = 0;
        for (int idx = 0; idx < n; idx++) {
            int i = s.charAt(idx) - 'a';
            if (cur + widths[i] > 100) {
                cur = 0;
                cnt++;
            }
            cur += widths[i];
        }
        return new int[]{cnt, cur};
    }
}
